package com.hm.oper_monitor.bean;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.hm.common.plugin.Page;
import com.hm.oper_monitor.constants.Constants;

@Component
public class ResourcesManager {
	
	@Autowired
	public ConfigPropertyBean configProp;

	@Autowired
	public ScreenViewPropertyBean screenViewProp;
	
	public Page page;
	public boolean isUpdateBusi = true;
	

	public ResourcesManager() {
		page = new Page();
		page.setDisplayLength(100);
	}

	public ConfigPropertyBean getConfigProp() {
		return configProp;
	}
	public void setConfigProp(ConfigPropertyBean configProp) {
		this.configProp = configProp;
	}
	public ScreenViewPropertyBean getScreenViewProp() {
		return screenViewProp;
	}
	public void setScreenViewProp(ScreenViewPropertyBean screenViewProp) {
		this.screenViewProp = screenViewProp;
	}

	public Page getPage() {
		return page;
	}

	public void setPage(Page page) {
		this.page = page;
	}
	public boolean isUpdateBusi() {
		return isUpdateBusi;
	}

	public void setUpdateBusi(boolean isUpdateBusi) {
		this.isUpdateBusi = isUpdateBusi;
	}
	public void initScreenSize(){
		Dimension windowSize = Toolkit.getDefaultToolkit().getScreenSize();
		int width = (int) windowSize.getWidth();
		int height = (int) windowSize.getHeight();
		if (this.getScreenViewProp().getScreenViewModel() == Constants.SCREEN_VIEW_MODEL_SYSTEM){
			this.getScreenViewProp().setScreenWidth(width);
			this.getScreenViewProp().setScreenHeight(height);
		} else {
			this.getScreenViewProp().setScreenWidth((int) (width * this.getScreenViewProp().getScreenWidthPercent()));
			this.getScreenViewProp().setScreenHeight((int) (height * this.getScreenViewProp().getScreenHeightPercent()));
			this.getScreenViewProp().setScreenX((int) ((width - this.getScreenViewProp().getScreenWidth()) / 2));
			this.getScreenViewProp().setScreenY((int) ((height - this.getScreenViewProp().getScreenHeight()) / 2));
		}
	}

}
